﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZengShanCha.DAL;

namespace ZengShanCha.BLL
{
    public class Advance
    {
        public void Insert1()
        {
            //定义SQL语句
            string sql = "insert into Employee(EmployeeName, Gender, NowAddress, IdNo,WeiXinNumber, PhoneNumber,OtherWork,EntryDate,PostId,DepartmentId) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', {8}, {9})";
            //获取用户输入
            Console.Write("请输入员工姓名：");
            string employeeName = Console.ReadLine();
            Console.Write("请输入员工性别：");
            string gender = Console.ReadLine();
            Console.Write("请输入员工现在住址：");
            string nowAddress = Console.ReadLine();
            Console.Write("请输入员工身份证号码：");
            string idNo = Console.ReadLine();
            Console.Write("请输入员工微信号码：");
            string weiXinNumber = Console.ReadLine();
            Console.Write("请输入员工电话号码：");
            string phoneNumber = Console.ReadLine();
            Console.Write("请输入员工其他工作：");
            string otherWork = Console.ReadLine();
            Console.Write("请输入员工入职日期：");
            string entryDate = Console.ReadLine();
            Console.Write("请输入员工职位编号：");
            int postId = int.Parse(Console.ReadLine());
            Console.Write("请输入员工部门编号：");
            int departmentId = int.Parse(Console.ReadLine());

            //替换占位符
            sql = string.Format(sql, employeeName, gender, nowAddress, idNo, weiXinNumber, phoneNumber, otherWork, entryDate, postId, departmentId);
            //调用通用类
            int result = SQLHelper.ExecuteNonQuery(sql);
            Console.WriteLine("受影响的行数：" + result);

        }

        public void Insert2(string name,string phone,string dress)
        {
            //定义SQL语句
            string sql = "SELECT 1 FROM guest.TongXun WHERE name=@Name AND phone=@Phone AND dress=@Dress";

         

           

            //封装参数
            //SqlParameter param1 = new SqlParameter("@EmployeeName", employeeName);
            //SqlParameter param2 = new SqlParameter("@Gender", gender);
            //。。。。。

            SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@Name", name),
                    new SqlParameter("@Phone", phone),
                    new SqlParameter("@Dress",dress),
                 
                };

            //调用通用类
            object resuld = SQLHelper.ExecuteScalar(sql, param);
            if (resuld != null)
            {

                MessageBox.Show("登录成功");



            }

            else {

                MessageBox.Show("查询未返回结果");


            }


          




        }
    }
}